package com.yanqu.road.server.timer.union.cross;

import com.yanqu.road.entity.player.UserHistoryAttribute;
import com.yanqu.road.logic.bussiness.player.UserHistoryAttributeBussiness;
import com.yanqu.road.pb.union.cross.CrossUnionProto;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.PlayerModule;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.manger.union.CrossUnionMgr;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.utils.executor.GeneralTask;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * 定时器：检查和同步玩家历史最高赚钱到商会跨服，要等CrossUnionMgr的isAllSync=true后
 */
public class CrossUnionMemberAbilityCheckTask extends GeneralTask {
    private static Logger logger = LogManager.getLogger(CrossUnionMemberAbilityCheckTask.class);
    private static boolean running = false;

    @Override
    public void doRun() {
        if (!running) {
            running = true;
            try {
                if (!CrossUnionMgr.isAllSync()) {
                    return;
                }

                List<Long> userIdList = CrossUnionMgr.getUnionMemberIdListByZeroAbilityAndOwnServer();
                CrossUnionMemberAbilitySyncTask.addWaitUpdateAbilityUser(userIdList);
            } catch (Exception e) {
                logger.error("MemberAbilityCheck error. ", e);
            } finally {
                running = false;
            }
        }
    }


}
